using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

using Acms.SqlDal;

namespace Acms.Bll
{
    public class UserPostVoteAverage : BaseItem
    {
        protected UserPostVoteAverage() : base() { }
        protected UserPostVoteAverage(Hashtable table) : base(table) { }
        protected UserPostVoteAverage(Hashtable table, List<UserPostVoteAverage> collection) : base(table, collection) { }

        public static UserPostVoteAverage CreateInstance()
        {
            return new UserPostVoteAverage();
        }

        private static UserPostVoteAverage Get(Hashtable table)
        {
            if (table != null)
            {
                return new UserPostVoteAverage(table);
            }
            else
            {
                return null;
            }
        }

        private static List<UserPostVoteAverage> Get(Hashtable[] tables)
        {
            if (tables != null)
            {
                List<UserPostVoteAverage> tmp = new List<UserPostVoteAverage>();
                foreach (Hashtable table in tables)
                {
                    tmp.Add(new UserPostVoteAverage(table, tmp));
                }
                return tmp;
            }
            else
            {
                return null;
            }
        }

        public static UserPostVoteAverage GetByPostId(int postId)
        {
            UserPostVoteAverageDal dal = new UserPostVoteAverageDal();
            return Get(dal.GetByPostId(postId));
        }

        protected override void Load(Hashtable table)
        {
            postId = (int)table[UserPostVoteAverageDal.Fields.PostId];
            average = (decimal)table[UserPostVoteAverageDal.Fields.Average];
        }

        private int postId;
    	public int PostId
	    {
	        get { return postId;}
	    }

        private decimal average;
        public decimal Average
        {
            get { return average; }
        }

        protected override Acms.SqlDal.Base CreateDal()
        {
            return new UserPostVoteAverageDal();
        }
    }
}
